package mc.support.web.service;

import java.util.Map;

/**
 * Created with IntelliJ IDEA. <br/>
 * Author: francis Yun    <br/>
 * Date: 2013-12-03  <br/>
 */
public abstract class ServiceSupport implements IServiceRouter {

    private IServiceRouter serviceRouter;

    public ServiceSupport() {
        serviceRouter = new ServiceRouterImpl();
        init();
    }

    abstract public void init();

    @Override
    public Object route(Class<?> interfaceType, Object service, Map<String, Object> params) {
        return serviceRouter.route( interfaceType, service, params );
    }

    @Override
    public Object route(Object service, Map<String, Object> params) {
        return serviceRouter.route( service, params );
    }

    @Override
    public void registerParamResolver(String paramKey, ParamResolver paramResolver) {
        serviceRouter.registerParamResolver( paramKey, paramResolver );
    }

    @Override
    public ParamResolver unregisterParamResolver(String paramKey) {
        return serviceRouter.unregisterParamResolver( paramKey );
    }

    @Override
    public void registerGlobalParamResolver(String paramKey, ParamResolver paramResolver) {
        serviceRouter.registerGlobalParamResolver( paramKey, paramResolver );
    }

    @Override
    public ParamResolver unregisterGlobalParamResolver(String paramKey) {
        return serviceRouter.unregisterGlobalParamResolver( paramKey );
    }

    @Override
    public void enableGlobalServiceCache(boolean enable) {
        serviceRouter.enableGlobalServiceCache( enable );
    }

}
